<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script>
var str = 'abced';
var a = str.slice(0,2);
alert(a);		//	ab

var str = '012345';
var a = str.slice(0,3);
alert(a);		//	012

</script>
</body>
</html>